#ifndef COLORHISTOGRAM_H
#define COLORHISTOGRAM_H

#include <vector>
#include <opencv/cv.h>
#include <opencv/highgui.h>

using namespace cv;
using namespace std;

namespace controllers {
    /**
     * @brief The ColorHistogram class is used to compute histogram
     *        of an image based on its pixel values (color).
     *
     * Adapted from:
     *      OpenCV2 Computer Vision Application programming Cookbook
     *      of Robert Laganière
     */
    class ColorHistogram
    {
    public:
        ColorHistogram();
        virtual         ~ColorHistogram();
        Mat             applyLookUp(const Mat& image, const Mat& lookup);
        Mat             equalize(const Mat &image);
        Mat             stretch(const Mat &image, int minValue = 0);
        void            colorReduce(Mat &image, int div = 64);

        MatND           getHistogram(const Mat &image);
        SparseMat       getSparseHistogram(const Mat &image);
        // Computes the 1D Hue histogram with a mask.
        // BGR source image is converted to HSV
        // Pixels with low saturation are ignored
        MatND           getHueHistogram(const Mat &image, int minSaturation = 0);
        vector<int>     getHistogramVector(int numBins = 0);

    private:
        int             _histSize[3];
        int             _channels[3];
        float           _hranges[2];
        const float*    _ranges[3];
    };
}

#endif // COLORHISTOGRAM_H
